<html>
<head>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <title>用户登录页面</title>


    <link href="/resource/plugins/assets/dist/css/default.css" rel="stylesheet" type="text/css" />
    <!--必要样式-->
    <link href="/resource/plugins/assets/dist/css/styles.css" rel="stylesheet" type="text/css" />
    <link href="/resource/plugins/assets/dist/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="/resource/plugins/assets/dist/css/loaders.css" rel="stylesheet" type="text/css" />
    <link href="/resource/js/layui/css/layui.css"  rel="stylesheet" type="text/css" />
    <!--[if !IE]> -->
    <script type="text/javascript">
        window.jQuery || document.write("<script src='/resource/plugins/assets/dist/js/jquery-2.0.3.min.js'>" + "<" + "script>");
    </script>
    <!--[endif]-->
    <!--[if IE]>-->
    <script type="text/javascript">
        window.jQuery || document.write("<script src='/resource/plugins/assets/dist/js/jquery-1.10.2.min.js'>" + "<" + "script>");
    </script>
    <![endif]-->
</head>
<body>
<div class='login'>
    <div class='login_title'>
        <span>管理员登录</span>
    </div>
    <div class='login_fields'>
        <div class='login_fields__user'>
            <div class='icon'>
                <img alt="" src='/resource/plugins/assets/dist/img/user_icon_copy.png'>
            </div>
            <input  placeholder='用户名' maxlength="20" type='text' autocomplete="off" id="userName" name="userName" required="true" data-require-msg="必填" />
            <div class='validation'>
                <img alt="" src='/resource/plugins/assets/dist/img/tick.png'>
            </div>
        </div>
        <div class='login_fields__password'>
            <div class='icon'>
                <img alt="" src='/resource/plugins/assets/dist/img/lock_icon_copy.png'>
            </div>
            <input  placeholder='密码' maxlength="20" type='text' autocomplete="off" id="pwd" name="passWord" require="true" data-require-msg="必填">
            <div class='validation'>
                <img alt="" src='/resource/plugins/assets/dist/img/tick.png'>
            </div>
        </div>
        <div class='login_fields__password'>
            <#--<div class='icon'>-->
                <#--<img alt="" src='img/key.png'>-->
            <#--</div>-->
            <#--<input name="code" placeholder='验证码' maxlength="4" type='text' name="ValidateNum" autocomplete="off">-->
            <div class='validation' style="opacity: 1; right: -5px;top: -3px;">
                <canvas class="J_codeimg" id="myCanvas" onclick="Code();">对不起，您的浏览器不支持canvas，请下载最新版浏览器!</canvas>
            </div>
        </div>
        <div class='login_fields__submit'>
            <input type='submit' value='登录' id="login">
        </div>
    </div>
    <div class='success'>
    </div>
    <div class='disclaimer'>
        <p>欢迎登录后台管理系统</p>
    </div>
</div>
<div class='authent'>
    <div class="loader" style="height: 44px;width: 44px;margin-left: 28px;">
        <div class="loader-inner ball-clip-rotate-multiple">
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
    <p>认证中...</p>
</div>
<div class="OverWindows"></div>


<script type="text/javascript" src="/resource/js/jquery-ui.min.js"></script>
<script type="text/javascript" src='/resource/js/stopExecutionOnTimeout.js?t=1'></script>
<script src="/resource/js/layui/layui.js" type="text/javascript"></script>
<script src="/resource/js/Particleground.js" type="text/javascript"></script>
<script src="/resource/js/Treatment.js" type="text/javascript"></script>
<script src="/resource/js/jquery.mockjax.js" type="text/javascript"></script>
<#--<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>-->
<#--<script src="/resource/js/layer/layer.js"></script>-->
<script src="/resource/script/lib/util.js"></script>
<#--<script src="/resource/js/jquery.validate.min.js"></script>-->
<script type="text/javascript">
    var canGetCookie = 0;//是否支持存储Cookie 0 不支持 1 支持
    var ajaxmockjax = 1;//是否启用虚拟Ajax的请求响 0 不启用  1 启用
    //默认账号密码

    var truelogin = "admin";
    var truepwd = "123456";

    var CodeVal = 0;
    Code();
    function Code() {
        if(canGetCookie == 1){
            createCode("AdminCode");
            var AdminCode = getCookieValue("AdminCode");
            showCheck(AdminCode);
        }else{
            showCheck(createCode(""));
        }
    }
    function showCheck(a) {
        CodeVal = a;
        var c = document.getElementById("myCanvas");
        var ctx = c.getContext("2d");
        ctx.clearRect(0, 0, 1000, 1000);
        ctx.font = "80px 'Hiragino Sans GB'";
        ctx.fillStyle = "#E8DFE8";
//        ctx.fillText(a, 0, 100);
    }
    $(document).keypress(function (e) {
        // 回车键事件
        if (e.which == 13) {
            $('input[type="submit"]').click();
        }
    });
    //粒子背景特效
    $('body').particleground({
        dotColor: '#E8DFE8',
        lineColor: '#133b88'
    });
    $('input[name="passWord"]').focus(function () {
        $(this).attr('type', 'password');
    });
    $('input[type="text"]').focus(function () {
        $(this).prev().animate({ 'opacity': '1' }, 200);
    });
    $('input[type="text"],input[type="password"]').blur(function () {
        $(this).prev().animate({ 'opacity': '.5' }, 200);
    });
    $('input[name="userName"],input[name="passWord"]').keyup(function () {
        var Len = $(this).val().length;
        if (!$(this).val() == '' && Len >= 5) {
            $(this).next().animate({
                'opacity': '1',
                'right': '30'
            }, 200);
        } else {
            $(this).next().animate({
                'opacity': '0',
                'right': '20'
            }, 200);
        }
    });
    var open = 0;
    layui.use('layer', function () {
        // var msgalert = '默认账号:' + truelogin + '<br/> 默认密码:' + truepwd;
        // var index = layer.alert(msgalert, { icon: 6, time: 4000, offset: 't', closeBtn: 0, title: '友情提示', btn: [], anim: 2, shade: 0 });
        // layer.style(index, {
        //     color: '#777'
        // });
        //非空验证
        $('input[type="submit"]').click(function () {
            var userName = $('input[name="userName"]').val();
            var pwd = $('input[name="passWord"]').val();
            if (userName == '') {
                ErroAlert('请输入您的账号');
            } else if (pwd == '') {
                ErroAlert('请输入密码');
            } else {
                //认证中..
                $('.login').addClass('test'); //倾斜特效
                setTimeout(function () {
                    $('.login').addClass('testtwo'); //平移特效
                }, 300);
                setTimeout(function () {
                    $('.authent').show().animate({ right: -320 }, {
                        easing: 'easeOutQuint',
                        duration: 600,
                        queue: false
                    });
                    $('.authent').animate({ opacity: 1 }, {
                        duration: 200,
                        queue: false
                    }).addClass('visible');
                }, 500);

                //登录
                var JsonData = { userName: userName, passWord: pwd};
                //此处做为ajax内部判断
                var url = window.BT.util.config.url.login;
                // if(JsonData.userName == truelogin && JsonData.passWord == truepwd ){
                //     url = "http://localhost:8125/api/vi/admin/login";
                // }


                AjaxPost(url, JsonData,
                        function () {
                            //ajax加载中
                        },
                        function (data) {
                            //ajax返回
                            //认证完成
                            setTimeout(function () {
                                $('.authent').show().animate({ right: 90 }, {
                                    easing: 'easeOutQuint',
                                    duration: 600,
                                    queue: false
                                });
                                $('.authent').animate({ opacity: 0 }, {
                                    duration: 200,
                                    queue: false
                                }).addClass('visible');
                                $('.login').removeClass('testtwo'); //平移特效
                            }, 2000);
                            setTimeout(function () {
                                $('.authent').hide();
                                $('.login').removeClass('test');
                                if (data.code == 0 ) {
                                    //登录成功
                                    $('.login div').fadeOut(100);
                                    $('.success').fadeIn(1000);
                                    $('.success').html(data.Text);
                                    //跳转操作
                                    window.localStorage.setItem(window.BT.util.API_KEY_NAME, data.token);
                                    window.location.href = '/platform/index';
                                } else {
                                   $.showPopup("登录失败");
                                }
                            }, 2400);
                        })
            }
        })
    })
</script>

</body>


</html>